package be.ac.ua.ecampus.uacmat.entity;

import java.sql.SQLException;
import java.util.Collection;
import java.util.HashSet;

import be.ac.ua.ecampus.uacmat.QueryHandler;

public class Course extends Entity {

	private Collection<Syllabus> fSyllabuses;
	private Collection<Program> fPrograms;

	public Course(String id, String description) {
		super("course", id, description);
		this.fSyllabuses = new HashSet<Syllabus>();
		this.fPrograms = new HashSet<Program>();
	}

	public Collection<Syllabus> getSyllabuses() throws SQLException {
		if (fSyllabuses.isEmpty()) {
			QueryHandler queryHandler = new QueryHandler();
			fSyllabuses = queryHandler.getSyllabusesForCourse(this.fId);
		}
		return fSyllabuses;
	}
	
	public Collection<Program> getPrograms() throws SQLException {
		if (fPrograms.isEmpty()) {
			QueryHandler queryHandler = new QueryHandler();
			fPrograms = queryHandler.getProgramsForCourse(this.fId);
		}
		return fPrograms;
	}
}
